package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.componentes.SupervisorWeb;
import br.com.caelum.vraptor.dao.SupervisorDAO;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Supervisor;
import br.com.caelum.vraptor.entidades.AvaliacaoAluno;

@Controller
public class SupervisorController {
	
	@Inject
	private Result result;
	
	@Inject
	private SupervisorDAO dao;

	@Inject
	private SupervisorWeb supervisorWeb;
	public void add(){
		
	}
	
	public List<Supervisor> list(){
		return dao.find();
	}
	public void login(){
		
	}
	
	public void logar(String email, String senha){
		Supervisor n = dao.find(email, senha);
		if(n==null){result.redirectTo(SupervisorController.class).login();}
		supervisorWeb.login(n);
		result.redirectTo(IndexController.class).index();
		
	}
	
	
	
	public void save(Supervisor supervisor){
		
		dao.save(supervisor);
		
		result.redirectTo(SupervisorController.class).login();
	}
	
	public Supervisor edit(Integer id){
		return dao.find(id);
	}
	
	public void delete(int id){
		Supervisor supervisor = new Supervisor();
		supervisor.setId(id);
		dao.delete(supervisor);
		result.redirectTo(SupervisorController.class).add();
	}
	
}
